#!/bin/sh
mount -o remount,rw /
INSTDIR=/media/cryptofs/apps
DBDIR=/var/home/root/.justinput/
PATCHDIR=$INSTDIR/usr/palm/applications/com.youjf.addons/
if [ -f "${DBDIR}/db/config.db" ]; then
    HackFile="/usr/palm/frameworks/mojo/mojo.js"
    StartLine=`sed -n "/justinput hack start/=" ${HackFile}`
    EndLine=`sed -n "/justinput hack end/=" ${HackFile}`
    if ((test ${StartLine} > 0) && (test ${EndLine} > 0)) then
        sed "${StartLine},${EndLine}d" "${HackFile}" > ${HackFile}.tmp
        mv -f ${HackFile}.tmp ${HackFile}
    fi

    # hack the mojo.js
    cat $PATCHDIR/mojo_append.js >> ${HackFile}
fi

exit 0
